package qdlimap.com.draglayoutlearn;

import android.app.Activity;
import android.content.DialogInterface;
import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentStatePagerAdapter;
import android.support.v4.view.ViewPager;
import android.view.View;
import android.widget.ImageView;

import com.nineoldandroids.view.ViewHelper;

import java.util.ArrayList;
import java.util.List;

import qdlimap.com.draglayoutlearn.DragLayoutLib.DragLayout;
import qdlimap.com.draglayoutlearn.DragLayoutLib.MainContentLayout;

public class MainActivity extends Activity implements View.OnClickListener {

    private DragLayout mDragLayout;
    private ImageView topbarLeftImage;
    private MainContentLayout mMainContent;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

        mDragLayout = (DragLayout) findViewById(R.id.dl);
        topbarLeftImage = (ImageView) findViewById(R.id.topbar_left_button);
        mMainContent = (MainContentLayout) findViewById(R.id.mainContent);
        mMainContent.setDragLayout(mDragLayout);
        topbarLeftImage.setOnClickListener(this);
        // StaticVariable.setmDragLayout(mDragLayout);\
        mDragLayout.setOnLayoutDragingListener(new DragLayout.OnLayoutDragingListener() {

            @Override
            public void onOpen() {

            }

            @Override
            public void onDraging(float percent) {
                ViewHelper.setAlpha(topbarLeftImage, 1 - percent);
            }

            @Override
            public void onClose() {

            }
        });
    }

    private class MyOnPageChangeListener implements ViewPager.OnPageChangeListener {

        @Override
        public void onPageScrollStateChanged(int arg0) {

        }

        @Override
        public void onPageScrolled(int position, float positionOffset,
                                   int positionOffsetPixels) {
        }

        @Override
        public void onPageSelected(int postion) {
            switch (postion) {
                case 0:
                    mDragLayout.setDrag(true);
                    break;
                case 1:
                    mDragLayout.setDrag(false);
                    break;
                case 2:
                    mDragLayout.setDrag(false);
                    break;
            }
        }
    }

    @Override
    public void onClick(View v) {
        switch (v.getId()) {
            case R.id.topbar_left_button:
                mDragLayout.open();
                break;
        }
    }
}
